<h1>My workreports</h1>

<% if @projects.blank? %>
You don't have any active project.
<% end %>

<% for project in @projects %>
	<h2><%= h project.title %></h2><p>
	
	<% if project.associated_unfinished_tasks.blank? %>
		<p>There are no task for you at '<%= h project.title %>'<p>
		<%= link_to 'Add task', new_task_path %>
	<% end %>
	
	<% for task in project.associated_unfinished_tasks %>
	<p><%= h task.name %>: <br />
	<%= link_to "New workreport", { :action => "new", :id => project.id } %>
	<table>
  <tr>
    <th>Date</th>
    <th>Time</th>
		<th></th>
  </tr>
		<% for workreport in task.workreports %>
			<tr>
				<td><%= link_to h(workreport.date.to_formatted_s(:long)), workreport %></td>
				<td><%=h workreport.time %></td>
				<td> 
				<!-- <%= link_to 'Edit', edit_workreport_path(workreport) %> | -->
				<%= link_to 'Destroy', workreport, :confirm => 'Are you sure?', :method => :delete %>
			</td>
			</tr>
		<% end %>
		</table>
	<% end %>
	</p>
<% end %>
</p>

